<template>
  <div>
    <div class="wrapper">
      <h2 class="title">{{ article && article.title }}</h2>
      <span class="time">发布日期 {{ article | fmtDate }}</span>
      <div class="content" v-html="article.content"></div>
    </div>
  </div>
</template>

<script>
import { get } from "@/utils/request.js";

export default {
  data() {
    return {
      id: this.$route.query.id,

      article: null,
    };
  },

  methods: {
    // 根据id查找文章 /index/article/findById
    async queryArticle() {
      let rsp = await get("/index/article/findById", {
        id: this.id,
      });

      console.log(rsp.data);
      this.article = rsp.data;
    },
  },
  created() {
    this.queryArticle();
  },
};
</script>

<style lang="scss" scoped>
.wrapper {
  .title {
    font-size: 36px;
    text-align: center;
    color: #666;
    line-height: 40px;
    padding: 25px 0;
  }
  .time {
    display: block;
    height: 46px;
    line-height: 46px;
    text-align: center;
    font-size: 18px;
    color: #666;
    background: #f5f5f5;
  }
  .content {
    margin-top: 24px;
    padding: 0 20px;
  }
}
</style>